/*  1:   */ package com.jetbrains.licenseService.util;
/*  2:   */ 
/*  3:   */

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */ 
/*  8:   */ public class RSADecoder
/*  9:   */ {
/* 10: 9 */   private static final byte[] a = new byte[0];
/* 11:   */   private final BigInteger b;
/* 12:   */   private final BigInteger c;
/* 13:   */   private final BigInteger d;
/* 14:   */   private final int e;
/* 15:   */   
/* 16:   */   public RSADecoder(BigInteger paramBigInteger1, BigInteger paramBigInteger2)
/* 17:   */   {
/* 18:16 */     this(paramBigInteger1, paramBigInteger2, 16);
/* 19:   */   }
/* 20:   */   
/* 21:   */   protected RSADecoder(BigInteger paramBigInteger1, BigInteger paramBigInteger2, int paramInt)
/* 22:   */   {
/* 23:20 */     this.d = paramBigInteger2;
/* 24:21 */     this.c = paramBigInteger1;
/* 25:22 */     int i = paramBigInteger2.bitLength();
/* 26:23 */     int j = (int)Math.ceil(i / Math.log(paramInt) * Math.log(2.0D));
/* 27:24 */     if (j % 5 != 0) {
/* 28:25 */       j = (j / 5 + 1) * 5;
/* 29:   */     }
/* 30:27 */     this.e = j;
/* 31:28 */     this.b = new BigInteger(Integer.toString(paramInt));
/* 32:   */   }
/* 33:   */   
/* 34:   */   public String decodeString(String paramString)
/* 35:   */     throws DecodeException
/* 36:   */   {
/* 37:   */     try
/* 38:   */     {
/* 39:33 */       return new String(decode(paramString), "UTF-8");
/* 40:   */     }
/* 41:   */     catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
/* 42:37 */     return "";
/* 43:   */   }
/* 44:   */   
/* 45:   */   public byte[] decode(String paramString)
/* 46:   */     throws DecodeException
/* 47:   */   {
/* 48:   */     try
/* 49:   */     {
/* 50:43 */       ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
/* 51:44 */       BigInteger localBigInteger1 = BigInteger.ZERO;
/* 52:45 */       int i = 0;
/* 53:46 */       for (int j = 0; j < paramString.length(); j++)
/* 54:   */       {
/* 55:47 */         char c1 = paramString.charAt(j);
/* 56:48 */         localBigInteger1 = localBigInteger1.multiply(this.b).add(a(c1));
/* 57:49 */         i++;
/* 58:50 */         if (i == this.e)
/* 59:   */         {
/* 60:51 */           BigInteger localBigInteger2 = localBigInteger1.modPow(this.c, this.d);
/* 61:52 */           localByteArrayOutputStream.write(localBigInteger2.toByteArray());
/* 62:53 */           localBigInteger1 = BigInteger.ZERO;
/* 63:54 */           i = 0;
/* 64:   */         }
/* 65:   */       }
/* 66:58 */       if (i != 0) {
/* 67:59 */         throw new DecodeException();
/* 68:   */       }
/* 69:62 */       localByteArrayOutputStream.close();
/* 70:63 */       return localByteArrayOutputStream.toByteArray();
/* 71:   */     }
/* 72:   */     catch (IOException localIOException) {}
/* 73:68 */     return a;
/* 74:   */   }
/* 75:   */   
/* 76:   */   private static BigInteger a(char paramChar)
/* 77:   */     throws DecodeException
/* 78:   */   {
/* 79:   */     int i;
/* 80:73 */     if (('0' <= paramChar) && (paramChar <= '9')) {
/* 81:74 */       i = paramChar - '0';
/* 82:76 */     } else if (('A' <= paramChar) && (paramChar <= 'Z')) {
/* 83:77 */       i = paramChar - 'A' + 10;
/* 84:79 */     } else if (('a' <= paramChar) && (paramChar <= 'z')) {
/* 85:80 */       i = paramChar - 'a' + 36;
/* 86:82 */     } else if (('!' <= paramChar) && (paramChar <= ')')) {
/* 87:83 */       i = paramChar - '!' + 62;
/* 88:   */     } else {
/* 89:86 */       throw new DecodeException();
/* 90:   */     }
/* 91:88 */     return BigInteger.valueOf(i);
/* 92:   */   }
/* 93:   */ }



/* Location:           E:\idea\

 * Qualified Name:     com.jetbrains.licenseService.util.RSADecoder

 * JD-Core Version:    0.7.0.1

 */